function hfile = root_New(hfile, type)
% ROOT::New  - create a new BVQXfile object
%
% FORMAT:       object = BVQXfile.new(type);
%
% Input fields:
%
%       type        3- or 4-letter type string (e.g. 'vmr')
%
% Output fields:
%
%       object      new object of requested type

% Version:  v0.7g
% Build:    9100822
% Date:     Oct-08 2009, 10:52 PM CEST
% Author:   Jochen Weber, SCAN Unit, Columbia University, NYC, NY, USA
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin ~= 2 || ...
    numel(hfile) ~= 1 || ...
   ~isBVQXfile(hfile, 'root') || ...
   ~ischar(type) || ...
   ~any((3:4) == numel(type))
    error( ...
        'BVQXfile:BadArgument', ...
        'Bad or missing argument.' ...
    );
end

% try to create object
try
    hfile = BVQXfile(['new:' type(:)']);
catch
    rethrow(lasterror);
end
